//
//  FooterView.m
//  Moment
//
//  Created by dllo on 15/12/22.
//  Copyright © 2015年 谭泽源. All rights reserved.
//

#import "FooterView.h"

@implementation FooterView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews
{
    //self.backgroundColor = [UIColor colorWithRed:0.22 green:0.22 blue:0.22 alpha:1];
    self.backgroundColor = [UIColor colorWithRed:0.454 green:0.484 blue:0.492 alpha:1.000];
    
    //专辑图片
    self.specialImageView = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/30, SCREEN_WIDTH/30, self.frame.size.height - SCREEN_WIDTH/15, self.frame.size.height - SCREEN_WIDTH/15)];
    self.specialImageView.image = [UIImage imageNamed:@"cm2_default_cover_240.png"];
    [self addSubview:self.specialImageView];

    //    self.specialImageView.backgroundColor = [UIColor redColor];
    
    
    //播放/停止按钮
    self.playBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.playBtn.frame = CGRectMake(self.frame.size.width - (self.frame.size.height - SCREEN_WIDTH/15 + SCREEN_WIDTH/30), SCREEN_WIDTH/30, self.frame.size.height - SCREEN_WIDTH/6, self.frame.size.height - SCREEN_WIDTH/6);
    [self addSubview:self.playBtn];
    //    [self.playBtn setImage:[UIImage imageNamed:@"iconfont-bofang"] forState:UIControlStateNormal];
    self.playBtn.center = CGPointMake(self.frame.size.width -  SCREEN_WIDTH/4, self.frame.size.height/2);
    if([[[NSUserDefaults standardUserDefaults]objectForKey:@"play"] isEqualToString:@"1"]){
        [self.playBtn setImage:[UIImage imageNamed:@"iconfont-zanting-2.png"] forState:UIControlStateNormal];
    }else{
        [self.playBtn setImage:[UIImage imageNamed:@"iconfont-bofang"] forState:UIControlStateNormal];
    }
    
    [self.playBtn addTarget:self action:@selector(playButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    //    self.playBtn.backgroundColor = [UIColor yellowColor];
    
    //标题
    self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.specialImageView.frame.origin.x +self.specialImageView.frame.size.width + SCREEN_WIDTH/30/2, self.specialImageView.frame.origin.y,self.playBtn.frame.origin.x - self.specialImageView.frame.size.width - SCREEN_WIDTH/15, 30)];
    [self addSubview:self.titleLabel];
    
    //    self.titleLabel.backgroundColor = [UIColor redColor];
    self.titleLabel.textColor = [UIColor colorWithRed:0.59 green:0.59 blue:0.59 alpha:1];
    self.titleLabel.font = [UIFont systemFontOfSize:15];
    
    //副标题
    self.subTitle = [[UILabel alloc]initWithFrame:CGRectMake(self.specialImageView.frame.origin.x +self.specialImageView.frame.size.width + SCREEN_WIDTH/30/2, self.titleLabel.frame.origin.y + self.titleLabel.frame.size.height + SCREEN_WIDTH/30/2, self.playBtn.frame.origin.x - self.specialImageView.frame.size.width - SCREEN_WIDTH/15, 20)];
    self.subTitle.font = [UIFont systemFontOfSize:15];
    [self addSubview:self.subTitle];
    
    //    self.subTitle.backgroundColor = [UIColor redColor];
    self.subTitle.textColor = [UIColor colorWithRed:0.59 green:0.59 blue:0.59 alpha:1];
    self.subTitle.font = [UIFont systemFontOfSize:12];
    self.isSelected = NO;
    
}


- (void)playButtonAction:(UIButton *)playAction
{
    if (_isSelected == NO) {
        [_playBtn setImage:[UIImage imageNamed:@"iconfont-zanting"] forState:UIControlStateNormal];
        DHMusicPlayerViewController *musicVC = [DHMusicPlayerViewController shareMusicPlayerViewController];
    
    }
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
